You will need a few lines of code to generate a random number:
Random random =new Random();int my_number = random.Next(0, 100);//returns a number between 0 and 100
Go ahead and create your own guessing game program. Name the project GuessingGame. Try to make the output as close as possible to the sample program provided above. Remember, the general flow of the program will be something like this:
Create a random number (the answer).
Ask the user for input
Convert the input from a string to an integer
Compare the input to the random number
Output "higher" or "lower" (and repeat) if NOT equal
Guessing Game
<-- Prev --------- Contents --------- Next -->The Guessing Game should bring together everything you have learned in the previous lessons.
To see an example of this program, download this and give it a try.
Code that you will need:
Variables to consider:
Random Number Generator
You will need a few lines of code to generate a random number:
Go ahead and create your own guessing game program. Name the project GuessingGame. Try to make the output as close as possible to the sample program provided above. Remember, the general flow of the program will be something like this:
Have fun!
<-- Prev --------- Contents --------- Next -->